<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>

        /*外边距:盒子与盒子之间的距离*/
        div{
            width:100px;
            height: 100px;
        }
        .d1{
            background:yellowgreen;
            display: inline-block;

            /*按方向设置*/
            margin-left:20px;
            margin-right:40px;
        }
        .d2{
            background:gold;
            display: inline-block;
        }
        .parent{
            width:300px;
            height: 300px;
            /*边框:边框宽度  线条样式  线条颜色*/
            border:1px solid red;
        }
        .child{
            width:100px;
            height: 100px;
            border:1px solid gray;
            margin-left:10px;
            margin-top:20px;

        }
    </style>
</head>
<body>
    <div class="d1"></div>
    <div class="d2"></div>
    <hr>
    <div class="parent">
        <div class="child"></div>
    </div>
</body>
</html>